package cn.stylefeng.guns.modular.rest.basic;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.stylefeng.guns.modular.basic.model.params.BasicOperateParam;
import cn.stylefeng.guns.modular.basic.service.BasicOperateService;
import cn.stylefeng.guns.modular.rest.aop.UserAop;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;

/**
 * 项目部控制器
 */
@Controller
@RequestMapping("/rest/operate")
public class restOperateController extends BaseController {
	
    @Autowired
    private UserAop userAop;

    @Autowired
    private BasicOperateService basicOperateService;

    /**
     * 查询 所属项目
     */
    @ResponseBody
    @RequestMapping("/findme")
    public ResponseData findme(BasicOperateParam param) {
    	User user = userAop.getUser();
    	param.setDeptId(user.getDeptId());
		return ResponseData.success(basicOperateService.findBySpec(param,user.getOperateId()));
    }

    /**
     * 项目部列表
     */
    @ResponseBody
    @RequestMapping("/list")
    public ResponseData list() {
    	User user = userAop.getUser();
        return ResponseData.success(basicOperateService.findAvailableList(user.getDeptId(),user.getDeliverId(),user.getOperateId()));
    }

    /**
     * 项目部列表
     */
    @ResponseBody
    @RequestMapping("/list2")
    public ResponseData list2() {
        return ResponseData.success(basicOperateService.findAvailableList(null,null,null));
    }

    /**
     * 项目部列表
     */
    @ResponseBody
    @RequestMapping("/list3")
    public ResponseData list3() {
    	User user = userAop.getUser();
        return ResponseData.success(basicOperateService.findAvailableList(null,user.getDeliverId(),null));
    }

}
